import { ref } from "vue";
import { useRouter } from "vue-router";
const useHeaderState = () => {
  /**-----------------------------  选中跳转页面   ---------------------------------------------- */
  const isActive = ref<number>(-1); //判断是否选中当前高亮元素
  const router = useRouter(); //获取router实例
  const toIndex = () => {
    isActive.value = 0;
    router.push({
      name: "Index",
    });
  };
  const toDiscovery = () => {
    isActive.value = 1;
    router.push({
      name: "Discovery",
    });
  };
  const toTraining = () => {
    isActive.value = 2;
    router.push({
      name: "Training",
    });
  };
  const toCommunication = () => {
    isActive.value = 3;
    router.push({
      name: "Communication",
    });
  };
  const toMy = () => {
    isActive.value = 4;
    router.push({
      name: "Dynamics",
    });
  };
  const toHome = () => {
    router.push({
      name: "Home",
    });
  };
  /**---------------------------- 暴露数据    ————————————------------------------------------------- */
  return {
    isActive,
    toIndex,
    toDiscovery,
    toTraining,
    toCommunication,
    toMy,
    toHome,
  };
};
export default useHeaderState;
